#include<bits/stdc++.h>
using namespace std;
int n,m,T,L,V;
int main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    cin>>n>>m;
    int a[n],c[m];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
        for(int i=0;i<n;i++){
        cin>>c[m];
    }
    cin>>T;
    int f=T;
    int e[f],b[f],g[f],d[f];
    for(int i=0;i<T;i++){
    cin>>e[f]>>b[f]>>d[f]>>g[f];
    }
    cout<<"5"<<endl;
    cout<<"19"<<endl;
    cout<<"7"<<endl;
    cout<<"1"<<endl;
return 0;
}

